using System.Web;

namespace Sail.Utility.Extensions
{
    public static class HttpRequestExtensions
    {
        public static string ToRootUrlString(this HttpRequestBase request)
        {
            return string.Format("{0}://{1}", request.Url.Scheme, request.Headers["Host"]);
        }

        public static string ToRootUrlString(this HttpRequest request)
        {
            return string.Format("{0}://{1}", request.Url.Scheme, request.Headers["Host"]);
        }

        public static string ToApplicationRootUrlString(this HttpRequestBase request)
        {
            string url = string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"],
                                       request.ApplicationPath);
            return url;
        }

        public static string ToApplicationRootUrlString(this HttpRequest request)
        {
            string url = string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"],
                                       request.ApplicationPath);
            return url;
        }

        public static string ToUrlString(this HttpRequestBase request)
        {
            return string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"], request.RawUrl);
        }

        public static string ToUrlString(this HttpRequest request)
        {
            return string.Format("{0}://{1}{2}", request.Url.Scheme, request.Headers["Host"], request.RawUrl);
        }
    }
}